package co.yixiang.modules.grandmaster.rest;

import co.yixiang.api.ApiResult;
import co.yixiang.common.interceptor.AuthCheck;
import co.yixiang.modules.grandmaster.service.YxGrandmasterService;
import co.yixiang.modules.grandmaster.service.dto.YxGrandmasterPage;
import co.yixiang.modules.representativeWork.domain.YxRepresentativeWork;
import co.yixiang.modules.representativeWork.service.YxRepresentativeWorkService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: DaiALong
 * @Description:
 * @Date: Created in 2021/8/12 14:01
 */
@Slf4j
@RestController
@Api(value = "认识大师", tags = "认识大师:认识大师", description = "认识大师")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class YxAppGrandmasterController {

    private final YxGrandmasterService yxGrandmasterService;
    private final YxRepresentativeWorkService yxRepresentativeWorkService;

    /**
     * 获取认识大师分页列表
     *
     */
    @AuthCheck
    @GetMapping("/grandmaster/getGrandmasterPage")
    @ApiOperation(value = "认识大师", notes = "认识大师")
    public ApiResult<Page<YxGrandmasterPage>> getGrandmasterPage(@RequestParam(value = "page",defaultValue = "1") int page, @RequestParam(value = "limit",defaultValue = "10") int limit) {
        return yxGrandmasterService.getGrandmasterPage(page,limit);
    }


    /**
     * 大师详情
     *
     */
    @AuthCheck
    @GetMapping("/grandmaster/getGrandmasterDetails")
    @ApiOperation(value = "大师详情", notes = "大师详情")
    public ApiResult getGrandmasterDetails(@RequestParam Integer id) {
        return yxGrandmasterService.getGrandmasterDetails(id);
    }



    /**
     * 获取大师代表作品分页列表
     *
     */
    @AuthCheck
    @GetMapping("/grandmaster/getRepresentativeWorkPage")
    @ApiOperation(value = "代表作品", notes = "代表作品")
    public ApiResult<Page<YxRepresentativeWork>> getRepresentativeWorkPage(@RequestParam int grandmasterId, @RequestParam(value = "page",defaultValue = "1") int page, @RequestParam(value = "limit",defaultValue = "10") int limit) {
        return yxRepresentativeWorkService.getRepresentativeWorkPage(grandmasterId,page,limit);
    }

}
